package com.lidong.framework.model;

public class ResultMessage {
	
	private final static int CODE_SUCCESS = 0;
	private final static int CODE_ERROR = -1;

	public static ResultMessage success() {
		return success(null);
	}
	
	public static ResultMessage success(String message) {
		return success(message, null);
	}
	
	public static ResultMessage success(int code, String message) {
        return success(code, message, null);
    }

	public static ResultMessage success(Object data){
		return success(CODE_SUCCESS, null, data);
	}

    public static ResultMessage success(String message, Object data){
        return success(CODE_SUCCESS, message, data);
    }
    
    public static ResultMessage success(int code, String message, Object data){
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(code);
        resultMessage.setSuccess(true);
        resultMessage.setMessage(message);
        resultMessage.setData(data);
        return resultMessage;
    }

	public static ResultMessage error() {
		return error(null);
	}
	
	public static ResultMessage error(String message) {
		return error(CODE_ERROR, message, null);
	}
	
	public static ResultMessage error(int code, String message) {
		return error(code, message, null);
	}
	
	public static ResultMessage error(String message, Object data) {
		return error(CODE_ERROR, message, data);
	}

    public static ResultMessage error(int code, String message, Object data){
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(code);
        resultMessage.setSuccess(false);
        resultMessage.setMessage(message);
        resultMessage.setData(data);
        return resultMessage;
    }

	/**
	 * 是否错误
	 */
	private boolean success;
	/**
	 * 错误编号
	 */
	private int code;
	/**
	 * 信息
	 */
	private String message;
    /**
     * 数据
     */
    private Object data;
    
	public boolean getSuccess() {
		return success;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public Object getData() {
		return data;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public void setData(Object data) {
		this.data = data;
	}
}